import { POST } from '@/utils/request'

function _mockApiResult(result: unknown): ApiResponseData {
  return { code: 200, message: '操作成功', success: true, timestamp: Date.now(), result }
}

/** 避免 hooks 写法下的命名冲突 */
export class LoginService {
  /** 登录 */
  static login(data: LoginEntity.LoginParams) {
    return POST('/auth/login', data)
  }

  /** 退出登录 */
  static logout() {
    return new Promise((resolve, _) => resolve(_mockApiResult('退出成功')))
  }

  /** 注册用户 */
  static register(data: LoginEntity.RegisterParams) {
    return POST('/auth/register', data)
  }
}
